home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
ddj0897.zip
/
AA897.ASC
next >
Wrap
Text File
|
1997-06-20
|
768b
|
36 lines
_Algorithm Alley: Topological Sorting_
by Jonathan Pincus and Jerry Schwarz
Example 1:
topsort reports (correctly) that there is a cycle after 1 element
a
cycles reports (correctly) that there are two cycles
cycle 0: g f
cycle 1: d c b
topsortWithCycles reports (correctly) that there is a cycle
a
d
c
b
e
g
f
Example 2:
template<class RandomAccessIterator,
class InputIterator,
class OutputIterator>
int
topsort (RandomAccessIterator begin,
RandomAccessIterator end, // members being sorted
InputIterator beginRel,
InputIterator endRel, // relations being sorted
OutputIterator result
)